﻿using DocumentFormat.OpenXml.Lite.Helper;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Types;
using DocumentFormat.OpenXml.Lite.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace DocumentFormat.OpenXml.Lite.WordprocessingML.Word.ParagraphProperties
{
    [XmlRoot("spacing", Namespace = Constants.WordMain)]
    public class Spacing : XmlSerializable, IParagraphPropElement
    {
        [Optional]
        [XmlAttribute("before", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<uint> Before {get;set;}

        [Optional]
        [XmlAttribute("beforeLines", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<int> BeforeLines {get;set;}

        [Optional]
        [XmlAttribute("beforeAutospacing", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<ST_OnOff> BeforeAutospacing {get;set;}

        [Optional]
        [XmlAttribute("after", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<int> After {get;set;}

        [Optional]
        [XmlAttribute("afterLines", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<ST_OnOff> AfterLines {get;set;}

        [Optional]
        [XmlAttribute("afterAutospacing", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<uint> AfterAutospacing {get;set;}

        [Optional]
        [XmlAttribute("line", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<int> Line {get;set;}

        [Optional]
        [XmlAttribute("lineRule", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<ST_LineSpacingRule> LineRule { get; set; }

        public Spacing() { }

        public void Copy(object obj)
        {
            if (obj is Spacing)
            {
                this.Before = (obj as Spacing).Before;
                this.BeforeLines = (obj as Spacing).BeforeLines;
                this.BeforeAutospacing = (obj as Spacing).BeforeAutospacing;

                this.After = (obj as Spacing).After;
                this.AfterLines = (obj as Spacing).AfterLines;
                this.AfterAutospacing = (obj as Spacing).AfterAutospacing;

                this.Line = (obj as Spacing).Line;
                this.LineRule = (obj as Spacing).LineRule;
            }
        }
    }
}
